﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ImageQueryImageApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FileDialog fileDialog = new OpenFileDialog();
            fileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;";
            fileDialog.Title = "选择图片";
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                string filePath = fileDialog.FileName;
                textBox1.Text = filePath;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text))
            {
                MessageBox.Show("请先选择图片文件");
                return;
            }
            if (radioButton1.Checked)
            {

                richTextBox1.Text = TXHelper.QueryImage(textBox1.Text);

            }
            else if ((radioButton2.Checked))
            {
                richTextBox1.Text = ALHelper.QueryImage(textBox1.Text);
            }
            else if (radioButton3.Checked)
            {
                richTextBox1.Text = BDHelper.QueryImage(textBox1.Text);
            }
            else
            {
                MessageBox.Show("请先选择搜索引擎");
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text))
            {
                MessageBox.Show("请先选择图片文件");
                return;
            }
            if (radioButton1.Checked)
            {
                richTextBox1.Text = TXHelper.UploadImage(textBox1.Text);

            }
            else if ((radioButton2.Checked))
            {
                richTextBox1.Text = ALHelper.UploadImage(textBox1.Text);
            }
            else if (radioButton3.Checked)
            {
                richTextBox1.Text =BDHelper.UploadImage(textBox1.Text);
            }
            else
            {
                MessageBox.Show("请先选择搜索引擎");
            }
        }
    }
}
